//
// Created by hjie on 23-5-15.
//

#pragma once

#include "redis_message.h"
#include <cstdint>
#include <mutex>
#include <condition_variable>
#include "redis_message_request.h"

class RedisMessageReply
{
public:
    RedisMessageReply();
    ~RedisMessageReply();
    EmRedisParseStatus ParseData(const std::string & msg);
    EmRedisParseStatus ParseData(const uint8_t * data, int length, int & use_size);
public:
    std::string  String();
    int64_t Number();
    std::vector<RedisMessageReply> Array();
    std::string Error();
    RedisMessageType GetMsgType();
    bool IsNumber();
    bool IsString();
    bool IsArray();
    bool IsError();
private:
    RedisMessage * m_message;
};


class RedisMessageResponse
{
public:
    RedisMessageResponse();
    ~RedisMessageResponse();
public:
    int m_timeout_ms{2000};
    int m_is_async;
    int64_t m_index;
    RedisMessageRequest m_request;
    RedisMessageReply * m_reply;  
public:
    std::mutex m_mtx;
    std::condition_variable m_conf;
};





